<template>
	<div class="video-content">

	</div>
</template>

<script>

	export default {
		name: "videp",
		mounted() {


      // if (!this._isMobile()){
      //   window.location.href=location.protocol + "//" + location.host+"/pc"
      //   console.log('进入PC端')
      // }else {
      //   window.location.href=location.protocol + "//" + location.host + "/#/index";
      //   console.log('进入phone端')
      // }

      var mobile_flag = this.isMobile(); // true为PC端，false为手机端
      console.log(mobile_flag)
      if(mobile_flag){
        window.location.href=location.protocol + "//" + location.host + "/#/index";
        console.log('进入phone端')
      }else {
        window.location.href=location.protocol + "//" + location.host+"/pc"
        console.log('进入PC端')
      }
      console.log('结果'+ this.isMobile())
		},
		methods: {
      _isMobile() {
        let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
        return flag;
      },
      isMobile(){
        var userAgentInfo = navigator.userAgent;
        var mobileAgents = [ "Android", "iPhone", "SymbianOS", "Windows Phone", "iPad","iPod"];
        var mobile_flag = false;
        //根据userAgent判断是否是手机
        for (var v = 0; v < mobileAgents.length; v++) {
          if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
            mobile_flag = true;
            return mobile_flag;
          }
        }
        console.log("方法一" , mobile_flag)

        var screen_width = document.body.clientWidth;
        var screen_height =document.body.clientHeight;
        //根据屏幕分辨率判断是否是手机
        if(screen_width < 500 || screen_height < 800){
          mobile_flag = true;
          return mobile_flag
        }
        console.log("方法二" , mobile_flag , screen_width)

        var systems = {};
        var p = navigator.platform;
        systems.win = p.indexOf("Win") == 0;
        systems.mac = p.indexOf("Mac") == 0;
        if (systems.win || systems.mac) {//如果是电脑
          mobile_flag = false
        } else { //如果是手机,
          mobile_flag = true;
          return mobile_flag;
        }
        console.log( '方法三',mobile_flag)


        var system = {}
        system.pingtai = /(Win32|Win16|WinCE|Mac68K|MacIntel|MacIntel|MacPPC|Linux mips64)/i.test(navigator.platform);
        if (system.pingtai) {
          //电脑
          mobile_flag = false
        } else {
          //手机
          mobile_flag = true;
          return mobile_flag;
        }
        console.log( '方法四',mobile_flag)


        return mobile_flag;
      }
		},

		computed: {

		},
	}
</script>

<style lang="scss" scoped>

</style>
